* Stata code to replicate analysis in Benjamin O. Fordham and Victor Asal, 
* "Billiard Balls or Snowflakes: Major Power Prestige and the International 
* Diffusion of Institutions and Practices"

* The code requires the installation of Richard Tucker's btscs package to
* generate splines, Scott Long and Jeremy Freese's spost routines to 
* generate the model comparison statistics, and Gary King, Michael Tomz, 
* and Jason Wittenberg's CLARIFY software to produce predicted values.  
* Variables are labeled in the associated replication data file, 'FordhamAsal.dta'.

* Transition model of democratic onset and collapse
* For an explanation of the method, see Beck, et al. (2001).
* The onset model is estimated first

drop if major==1
recode demdepend 0=. if year < 1885
recode propdem 0=. if year < 1875
tsset ccode year
btscs demonset year ccode, g(autyrs) nspline(3) failure

* These models are run in order to generate the BIC statistics reported at the
* foot of Table 1.  The results are not reported in the paper.
corr demshrmaj time dwmajdem dempower
quietly probit demonset propdem mpalldem autyrs _prefail _spline1 _spline2 _spline3, robust
quietly fitstat, saving(none)
quietly probit demonset time propdem mpalldem autyrs _prefail _spline1 _spline2 _spline3, robust
quietly fitstat, saving(time)
probit demonset dwmajdem propdem mpalldem autyrs _prefail _spline1 _spline2 _spline3, robust
quietly fitstat, saving(dist)
probit demonset dempower propdem mpalldem autyrs _prefail _spline1 _spline2 _spline3, robust
quietly fitstat, saving(cinc)
quietly probit demonset demshrmaj propdem mpalldem autyrs _prefail _spline1 _spline2 _spline3, robust
fitstat, using(none)
fitstat, using(time)
fitstat, using(dist)
fitstat, using(cinc)

* These two models appears in the first two columns of Table 1
probit demonset demshrmaj mpalldem propdem autyrs _prefail _spline1 _spline2 _spline3 if gdppc~=., robust
quietly fitstat, saving(lim)
probit demonset demshrmaj mpalldem propdem gdppc autyrs _prefail _spline1 _spline2 _spline3, robust
fitstat, using(lim)

estsimp probit demonset demshrmaj mpalldem propdem autyrs _prefail _spline1 _spline2 _spline3, robust nolog sims(10000)

* Effect of major power democracy
setx demshrmaj 0 (propdem mpalldem autyrs _prefail _spline1 _spline2 _spline3) mean
simqi, prval(1) level(95)
setx demshrmaj 1 (propdem mpalldem autyrs _prefail _spline1 _spline2 _spline3) mean
simqi, prval(1) level(95)

* Effect of democracy among major power allies
setx mpalldem 0 (propdem demshrmaj autyrs _prefail _spline1 _spline2 _spline3) mean
simqi, prval(1) level(95)
setx mpalldem 1 (propdem demshrmaj autyrs _prefail _spline1 _spline2 _spline3) mean
simqi, prval(1) level(95)

* Effect of geographic diffusion
setx propdem 0 (demshrmaj mpalldem autyrs _prefail _spline1 _spline2 _spline3) mean
simqi, prval(1) level(95)
setx propdem 1 (demshrmaj mpalldem autyrs _prefail _spline1 _spline2 _spline3) mean
simqi, prval(1) level(95)

* This is the model of democratic collapse.
* These models were run for the sake of comparison.  They
* are mentioned in the paper, but the results are not reported.
drop _prefail _spline1 _spline2 _spline3 _tuntilf _frstfl
btscs demcollapse year ccode, g(demyrs) nspline(3) failure
probit demcollapse demshrmaj mpalldem propdem demyrs _prefail _spline1 _spline2 _spline3, robust nolog
probit demcollapse dempower mpalldem propdem demyrs _prefail _spline1 _spline2 _spline3, robust nolog
probit demcollapse dwmajdem mpalldem propdem demyrs _prefail _spline1 _spline2 _spline3, robust nolog
probit demcollapse demshare1 mpalldem propdem demyrs _prefail _spline1 _spline2 _spline3, robust nolog

* These results appear in the third and fourth columns of Table 1
probit demcollapse demshrmaj mpalldem propdem demyrs _prefail _spline1 _spline2 _spline3 if gdppc~=., robust nolog 
quietly fitstat, saving(lim)
probit demcollapse demshrmaj mpalldem propdem gdppc demyrs _prefail _spline1 _spline2 _spline3, robust nolog
fitstat, using(lim)

* This is the analysis of women's political equality, which appears
* in Table 2.  It is necessary to reload the dataset before running
* these models in order to facilitate the recomputation of the splines
* and ancillary variables generated by CLARIFY

* Dropping major powers except China, which had suffrage before becoming a major.
drop if ccode==2
drop if ccode==200
drop if ccode==220
drop if ccode==300
drop if ccode==325
drop if ccode==365
drop if ccode==255
drop if ccode==365
drop if ccode==740

* Dropping states with no post-1885 observations
drop if ccode==267
drop if ccode==245
drop if ccode==987
drop if ccode==99
drop if ccode==240
drop if ccode==273
drop if ccode==275
drop if ccode==730
drop if ccode==280
drop if ccode==332
drop if ccode==564
drop if ccode==335
drop if ccode==269
drop if ccode==337
drop if ccode==329
drop if ccode==89
drop if ccode==271
drop if ccode==511
drop if ccode==990
drop if ccode==80
drop if ccode==221
drop if ccode==223
drop if ccode==232
drop if ccode==331
drop if ccode==342
drop if ccode==930
drop if ccode==935
drop if ccode==946
drop if ccode==947
drop if ccode==955
drop if ccode==970
drop if ccode==983
drop if ccode==.
drop if suffrage==.

* Correcting Germany 1918 anomaly
replace wsshrmaj=0 if year==1918

tsset ccode year
btscs suffrage year ccode, g(nwsyrs) nspline(3) failure

* These models are estimated to generate the BIC statistics
* reported at the foot of Table 2
corr wsshrmaj dwsuffrage wspower time
quietly probit suffrage propwsreg mpallws nwsyrs _spline1 _spline2 _spline3
quietly fitstat, saving(none)
quietly probit suffrage time propwsreg mpallws nwsyrs _spline1 _spline2 _spline3 
quietly fitstat, saving(time)

* This model is reported in Table 2; the others are not.
probit suffrage dwsuffrage propwsreg mpallws nwsyrs _spline1 _spline2 _spline3 
quietly fitstat, saving(dist)
probit suffrage wspower propwsreg mpallws nwsyrs _spline1 _spline2 _spline3 
quietly fitstat, saving(cinc)
quietly probit suffrage wsshrmaj propwsreg mpallws nwsyrs _spline1 _spline2 _spline3 
fitstat, using(none)
fitstat, using(time)
fitstat, using(dist)
fitstat, using(cinc)

* Simulated confidence interval for wspower at max and min values
estsimp probit suffrage wsshrmaj mpallws propwsreg nwsyrs _spline1 _spline2 _spline3, robust nolog sims(10000)
setx wsshrmaj 0 (propwsreg mpallws nwsyrs _spline1 _spline2 _spline3) mean
simqi, prval(1) level(95)
setx wsshrmaj 1 (propwsreg mpallws nwsyrs _spline1 _spline2 _spline3) mean
simqi, prval(1) level(95)

* Simulated confidence intervals for propws at max and min values
setx propwsreg 0 (wsshrmaj mpallws nwsyrs _spline1 _spline2 _spline3) mean
simqi, prval(1) level(95)
setx propwsreg 1 (wsshrmaj mpallws nwsyrs _spline1 _spline2 _spline3) mean
simqi, prval(1) level(95)

* Analysis of purges, reported in Table 3
* Again, it is best to begin the with unaltered replication dataset

drop if major==1
drop if year < 1919
tsset ccode year
drop time
gen time=year-1919

* This tests whether a weighting of the major powers, all states, or
* no diffusion variable performs better.  Only the model using simple 
* proportion is reported in Table 3

corr majpurgelag wmajpurgelag dwmajpurgelag purgeprop1
quietly probit purge majpurgelag mpallpurge purge01500lag time polity2 if year < 2000 & wmajpurgelag~=. & majpurgelag~=. 
quietly fitstat, saving(maj)
probit purge wmajpurgelag mpallpurge purge01500lag time polity2 if year < 2000 & wmajpurgelag~=. & majpurgelag~=. 
quietly fitstat, saving(cinc)
probit purge dwmajpurgelag mpallpurge purge01500lag time polity2 if year < 2000 & wmajpurgelag~=. & majpurgelag~=. 
quietly fitstat, saving(dist)
quietly probit purge time mpallpurge purge01500lag polity2 if year < 2000 & wmajpurgelag~=. & majpurgelag~=.
fitstat, using(maj)
fitstat, using(cinc)
fitstat, using(dist)

* Model of purges indicates that purges in major powers are associated 
* with an increased probability of these actions in other states.
* The first of these models appears in Table 3
probit purge majpurgelag mpallpurge purge01500lag time polity2 if year < 2000, robust nolog
probit purge dwmajpurgelag mpallpurge purge01500lag time polity2 if year < 2000, robust nolog
probit purge wmajpurgelag mpallpurge purge01500lag time polity2 if year < 2000, robust nolog
probit purge purgeprop mpallpurge purge01500lag time polity2 if year < 2000, robust nolog

quietly estsimp probit purge majpurgelag mpallpurge purge01500lag time polity2 if year < 2000, robust nolog sims(10000)
* Effect of major power practice
setx majpurgelag 0 (purge01500lag time polity2) mean
simqi, prval(1) level(95)
setx majpurgelag 0.2 (purge01500lag time polity2) mean
simqi, prval(1) level(95)

* Effect of geographic diffusion
setx purge01500lag 0 (majpurgelag time polity2) mean
simqi, prval(1) level(95)
setx purge01500lag 1 (majpurgelag time polity2) mean
simqi, prval(1) level(95)

* Effect of time
setx time 0 (majpurgelag purge01500lag polity2) mean
simqi, prval(1) level(95)
setx time 81 (majpurgelag purge01500lag polity2) mean
simqi, prval(1) level(95)

* Effect of polity score
setx polity2 -10 (majpurgelag purge01500lag time) mean
simqi, prval(1) level(95)
setx polity2 10 (majpurgelag purge01500lag time) mean
simqi, prval(1) level(95)


